# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-rarfile
pkgname=('python2-rarfile' 'python-rarfile')
_pkgname=rarfile
pkgver=4.2
pkgrel=2
pkgdesc='RAR archive reader for Python.'
arch=('any')
url='https://pypi.org/project/rarfile/#files'
license=('ISC')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('fed3943a6d201d4832ee5377069ea400e58394590dd5022cdd7b6f6944c9bf1b6c26387aa0db4c56d5d82f6d10d0cecd2e438e224287cdbdb3314770848c14d8')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-rarfile() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

package_python-rarfile() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

